<%@tag import="java.util.ArrayList"%>
<%@tag import="java.util.List"%>
<%@tag import="by.epam.communalservices.entity.JkhTeam"%>
<%@tag import="by.epam.communalservices.dao.jdbc.JdbcDaoJkhTeam"%>
<%@tag import="java.sql.Connection"%>

<%@ attribute name="owner" %>
<%
	Connection con = (Connection) request.getSession().getAttribute("currentConnection");
	JdbcDaoJkhTeam jkhTeam = new JdbcDaoJkhTeam(con);
	List<JkhTeam> teamList = jkhTeam.findAll();
	Long owner = 0L;
	try {
	    owner = Long.parseLong( getJspContext().getAttribute("owner").toString() ); 
	} catch (Exception e) {
	}
	if (owner>0) {
		List<JkhTeam> newList = new ArrayList<JkhTeam>();
	    for (JkhTeam item : teamList) {
	        if (item.getIdOwner()==owner) {
	            newList.add(item);
	        }
	    }
		request.setAttribute("teamList", newList);
	} else {
		request.setAttribute("teamList", teamList);
	}
 %>